{% extends "common/layout.html" %}
{% block content %}


    <div class="row">
        <div class="col-sm-10 col-sm-offset-1">
            <div class="row">
                <div class="col-sm-10 ">
                    <h2>{{ parterindex.name }}
                        <button type="button" class="btn btn-success" data-toggle="modal"
                                data-target="#exampleModal" style="margin-left: 10px"><span
                                class="glyphicon glyphicon-open"
                                aria-hidden="true"></span>更新承建商信息
                        </button>
                    </h2>
                    <h4>
                        <span class="label label-primary">{{ parterindex.type }}</span>
                        <span class="label label-info">{{ parterindex.gctype }}</span>
                        <span class="label label-warning">{{ parterindex.zytype }}类</span>
                    </h4>

                </div>
            </div>
        </div>
    </div>

    {#    日期修改#}
    <div class="row updatedate" style="margin-top: 15px">
        <div class="col-sm-4 col-sm-offset-1">
            <div class="input-group">
                <span class="input-group-addon">预审日期</span>
                <a class='input-group date' id='datetimepicker1'>
                    <input type='text' class="form-control" id="ysdate" name="ysdate" value="{{ parterindex.ysdate }}"/>
                    <span class="input-group-addon">
		                    <span class="glyphicon glyphicon-calendar"></span>
		                </span>
                </a>
                <span class="input-group-btn">-</span>
                <span class="input-group-addon">考察日期</span>
                <a class='input-group date' id='datetimepicker2'>
                    <input type='text' class="form-control" id="kcdate" name="kcdate" value="{{ parterindex.kcdate }}"/>
                    <span class="input-group-addon">
		                    <span class="glyphicon glyphicon-calendar"></span>
		                </span>
                </a>

            </div>
        </div>
        <div class="col-sm-1">
            <a type="submit" class="btn btn-primary btn-block do-updatedate " id="doupdatedate">更新日期</a>
        </div>
    </div>


    <script type="text/javascript">

        $('#datetimepicker1').datetimepicker({
            format: 'YYYY-MM-DD',
            locale: moment.locale('zh-cn')
        });

        $('#datetimepicker2').datetimepicker({
            format: 'YYYY-MM-DD',
            locale: moment.locale('zh-cn')
        });

        {#更新日期#}
        var doupdatedate = {
            init: function () {
                this.eventBind()
            },
            eventBind: function () {
                $(".do-updatedate").click(function () {
                    var ysdate = $(".updatedate input[name=ysdate]").val();
                    var kcdate = $(".updatedate input[name=kcdate]").val();
                    var pid = "{{ parterindex.id }}";

                    var urlindex = common_ops.buildUrl("/parter/updatedate?pid=") + pid + "&ysdate=" + ysdate + "&kcdate=" + kcdate;
                    document.location.href = urlindex;

                });
            }
        };
        $(document).ready(function () {
            doupdatedate.init();
        });


    </script>

    <div class="row">
        <div class="col-sm-8 col-sm-offset-1" style="margin-top: 15px">

            {#        资质预审#}

            {% if onerecord.result =='通过' %}

                <h4>资格预审<span class="label label-success" style="margin-left: 5px">通过</span>
                    {% if onerecord.type %}
                        <span class="label label-primary" style="margin-left: 5px">{{ onerecord.type }}</span>
                    {% endif %}
                </h4>
                <div class="row" style="margin-top: 10px">
                    <row class="data-table">
                        <table class="table table-bordered table-hover">
                            <tr>
                                <th class="info">文件内容</th>
                                <th class="info">文件大小</th>
                                <th class="info">文件类型</th>
                                <th class="info">上传时间</th>
                                <th class="info">上传人员</th>
                                <th class="info">下载文件</th>
                            </tr>
                            {% for item in one %}
                                <tr>
                                    <th>{{ item.classtwo }}</th>
                                    <th>{{ item.size }}MB</th>
                                    <th>{{ item.type }}</th>
                                    <th>{{ item.created_time }}</th>
                                    <th>{{ item.creater.nickname }}</th>

                                    <th>
                                        <a class="btn btn-warning"
                                           href="{{ item.url }}" onclick="parteropenone">查看文件</a>
                                        <button type="button" class="btn btn-danger" data-toggle="modal"
                                                data-target="#conModal" data-id="{{ item.id }}">删除
                                        </button>
                                    </th>
                                </tr>

                                <script>
                                    function parteropenone() {
                                        var uid = {{ current_user.id }};
                                        var project = "{{ parterindex.name }}";
                                        var classone = "{{ item.classone }}";
                                        var classtwo = "{{ item.classtwo }}";

                                        $.ajax({
                                            url: common_ops.buildUrl("/record/parteropenrecord"),
                                            type: "POST",
                                            data: {
                                                part: "承建商信息档案存档",
                                                project: project,
                                                classone: classone,
                                                classtwo: classtwo,
                                                uid: uid,
                                                action: "查看",
                                            },
                                            dataType: 'json',
                                            success: function (res) {
                                            }
                                        });
                                    }
                                </script>

                            {% endfor %}
                        </table>
                    </row>
                </div>
            {% endif %}

            {% if onerecord.result =='不通过' %}

                <h4>资格预审<span class="label label-danger" style="margin-left: 5px">不通过</span></h4>
                <div class="alert alert-danger" role="alert">{{ onerecord.reason }}</div>

                {#               #}

            {% endif %}



            {#        考察评审#}
            {% if tworecord.result =='通过' %}

                <h4>考察评审<span class="label label-success" style="margin-left: 5px">通过</span>
                    {% if tworecord.type %}
                        <span class="label label-primary" style="margin-left: 5px">{{ tworecord.type }}</span>
                    {% endif %}
                </h4>
                <div class="row" style="margin-top: 10px">
                    <row class="data-table">
                        <table class="table table-bordered table-hover">
                            <tr>
                                <th class="info">文件内容</th>
                                <th class="info">文件大小</th>
                                <th class="info">文件类型</th>
                                <th class="info">上传时间</th>
                                <th class="info">上传人员</th>
                                <th class="info">下载文件</th>
                            </tr>
                            {% for item in two %}
                                <tr>
                                    <th>{{ item.classtwo }}</th>
                                    <th>{{ item.size }}MB</th>
                                    <th>{{ item.type }}</th>
                                    <th>{{ item.created_time }}</th>
                                    <th>{{ item.creater.nickname }}</th>


                                    <th>
                                        <a class="btn btn-warning"
                                           href="{{ item.url }}" onclick="parteropentwo()">查看文件</a>
                                        <button type="button" class="btn btn-danger" data-toggle="modal"
                                                data-target="#conModal" data-id="{{ item.id }}">删除
                                        </button>
                                    </th>
                                </tr>
                                <script>
                                    function parteropentwo() {
                                        var uid = {{ current_user.id }};
                                        var project = "{{ parterindex.name }}";
                                        var classone = "{{ item.classone }}";
                                        var classtwo = "{{ item.classtwo }}";

                                        $.ajax({
                                            url: common_ops.buildUrl("/record/parteropenrecord"),
                                            type: "POST",
                                            data: {
                                                part: "承建商信息档案存档",
                                                project: project,
                                                classone: classone,
                                                classtwo: classtwo,
                                                uid: uid,
                                                action: "查看",
                                            },
                                            dataType: 'json',
                                            success: function (res) {
                                            }
                                        });
                                    }
                                </script>

                            {% endfor %}
                        </table>
                    </row>
                </div>
            {% endif %}

            {% if tworecord.result =='不通过' %}
                <h4>资格预审<span class="label label-danger" style="margin-left: 5px">不通过</span></h4>
                <div class="alert alert-danger" role="alert">{{ tworecord.reason }}</div>

            {% endif %}


        </div>
    </div>



    {#    确认模态框#}
    <div class="modal fade" id="conModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
        <div class="modal-dialog" role="document">
            <div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span
                            aria-hidden="true">&times;</span></button>
                    <h4 class="modal-title" id="myModalLabel">操作确认</h4>
                </div>
                <div class="modal-body">
                    <p>是否确定删除?</p>
                    <input type="text" style="display:none" id="deleteid" name="deleteid">
                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
                    <button class="btn btn-danger do-delete" type="submit" name="delete" id="delete">确定删除</button>
                </div>
            </div>
        </div>
    </div>


    {#    模态框#}
    <div class="modal fade" id="exampleModal" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel">
        <div class="modal-dialog" role="document">
            {#    等待模态#}
            <div class="modal fade" id="loadingModal">
                <div style="width: 200px;height:20px; z-index: 20000; position: absolute; text-align: center; left: 50%; top: 50%;margin-left:-100px;margin-top:-10px">
                    <div class="progress progress-striped active" style="margin-bottom: 0;">
                        <div class="progress-bar" style="width: 100%;"></div>
                    </div>
                    <h5 style="color:black"><strong>正在上传文件，请耐心等待...</strong></h5>
                </div>
            </div>


            <div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span
                            aria-hidden="true">&times;</span></button>
                    <h4 class="modal-title" id="exampleModalLabel">更新承建商资料</h4>
                </div>
                <div class="modal-body">


                    {#多级选择#}
                    <script type="text/javascript">
                        $(function () {
                            function objInit(obj) {
                                return $(obj).html('<option>请选择</option>');
                            }

                            var arrData = {
                                "资格预审":
                                    {
                                        "承建商基本信息调查表（盖章）": "",
                                        "典型工程合同业绩表（近三年）（盖章）": "",
                                        "联系人授权书、身份证明及社保证明": "",
                                        "近三年年度财务审计报告": "",
                                        "承建商资格预审表（线下）": "",
                                        "公司营业执照、企业资质": "",
                                    },
                                "考察评审":
                                    {
                                        "承建商考察评审表": "",
                                        "承建商考察评审汇总": "",
                                    },


                            };
                            $.each(arrData, function (pF) {
                                $('#classone').append('<option>' + pF + '</option>');
                            });
                            $('#classone').change(function () {
                                objInit('#classtwo');
                                objInit('#selC');
                                $.each(arrData, function (pF, pS) {
                                    if ($('#classone option:selected').text() == pF) {
                                        $.each(pS, function (pT, pC) {
                                            $('#classtwo').append('<option>' + pT + '</option>');
                                        });
                                        $('#classtwo').change(function () {
                                            objInit('#selC');
                                            $.each(pS, function (pT, pC) {
                                                if ($('#classtwo option:selected').text() == pT) {
                                                    $.each(pC.split(","), function () {
                                                        $('#selC').append('<option>' + this + '</option>');
                                                    })
                                                }
                                            })

                                        });
                                    }
                                })
                            });
                        });
                    </script>

                    {#暂存变量#}
                    <input class="form-control" id="pid" name="pid" style="display:none" value="{{ parterindex.id }}">
                    <input class="form-control" id="uid" name="uid" style="display:none" value="{{ current_user.id }}">

                    <div class="form-group">
                        <label class="control-label">结果:</label>
                        <select class="form-control " name="result" id="selF" onchange="switchresult();">
                            <option value="0">请选择</option>
                            <option value="1">通过</option>
                            <option value="2">不通过</option>
                        </select>
                    </div>

                    {#根据选项展示通过/不通过控件#}
                    <script type="text/javascript">
                        function switchresult() {
                            var selectValue = $("select[name='result']").val();
                            if (selectValue == 2) {
                                $("#classoneformpass").hide();
                                $("#classtwoform").hide();
                                $("#uploadform").hide();
                                $("#passpost").hide();
                                $("#classoneformdeny").show();
                                $("#reasonform").show();
                                $("#denypostform").show();

                            }
                            if (selectValue == 1) {
                                $("#classoneformpass").show();
                                $("#classtwoform").show();
                                $("#uploadform").show();
                                $("#passpost").show();
                                $("#classoneformdeny").hide();
                                $("#reasonform").hide();
                                $("#denypostform").hide();
                            }
                        }
                    </script>

                    {#通过#}
                    <div class="form-group" style="display:none" id="classoneformpass">
                        <label class="control-label">考察阶段:</label>
                        <select class="form-control " name="classone" id="classone" onchange="showtype()">
                            <option>请选择</option>

                        </select>
                    </div>

                    {#考察评审展示结果#}
                    <script type="text/javascript">
                        function showtype() {
                            var selectValue = $("#classone").find("option:selected").text();
                            if (selectValue == '考察评审') {
                                $("#typeform").show();
                            } else {
                                $("#typeform").hide();
                            }
                        }
                    </script>


                    <div class="form-group" style="display:none" id="typeform">
                        <label class="control-label">考察通过结果</label>
                        <select class="form-control " name="kctype" id="kctype">
                            <option></option>
                            <option>名录</option>
                            <option>特批</option>

                        </select>
                    </div>

                    {##}
                    {#                    <div class="form-group" style="display:none" id="classtwoform">#}
                    {#                        <label class="control-label">文件类型:</label>#}
                    {#                        <select class="form-control " name="classtwo" id="classtwo">#}
                    {#                        </select>#}
                    {#                    </div>#}

                    <div class="form-group" style="display:none" id="uploadform">
                        <label class="control-label">上传文件:</label>
                        <div id="input">
                            <input id="upload_input" class="admin img-fluid" type="file" multiple="multiple">
                        </div>
                    </div>


                    <div class="modal-footer" style="display:none" id="passpost">
                        <button class="btn btn-success do-upload" enctype="multipart/form-data">确定上传
                        </button>
                    </div>


                    {#不通过#}
                    <div class="form-group" style="display:none" id="classoneformdeny">
                        <label class="control-label">考察阶段:</label>
                        <select class="form-control " name="classonedeny" id="classonedeny">
                            <option>请选择</option>
                            <option>资格预审</option>
                            <option>考察评审</option>
                        </select>
                    </div>


                    <div class="form-group" style="display:none" id="reasonform">
                        <label class="control-label">不通过原因:</label>
                        <textarea class="form-control" rows="5" id="reason" name="reason"
                                  placeholder="请输入"></textarea>
                    </div>


                    <div class="modal-footer" style="display:none" id="denypostform">
                        <button class="btn btn-success do-deny">确定
                        </button>
                    </div>


                </div>
            </div>
        </div>
    </div>


    {#删除数据#}
    <script>
        $(".do-delete").click(function () {
            var btnaction = $(this);
            if (btnaction.hasClass("disable")) {
                common_ops.alert("还没提交上去了，别瞎点")
                return
            }

            var deleteid = $("input[id=deleteid]").val();


            $.ajax({
                url: common_ops.buildUrl("/parter/detaildelete"),
                type: "GET",
                data: {
                    id: deleteid,
                },
                dataType: 'json',
                success: function (res) {
                    btnaction.removeClass("disabled");
                    var callback = null;
                    if (res.code == 200) {
                        callback = function () {
                        };
                    }
                    common_ops.alert(res.msg, callback);
                    setTimeout(function () {
                        $('#conModal').modal('hide');
                        $(".modal-backdrop.fade").hide();
                        window.location.href = common_ops.buildUrl("/parter/parterdetail?id=" + res.data.pid);
                        $("#exampleModal").trigger("click");
                    }, 1000)

                }
            });

        });
    </script>

    <script>
        {#删除赋值#}
        $('#conModal').on('show.bs.modal', function (event) {
            var button = $(event.relatedTarget);
            var deleteid = button.data('id');
            document.getElementById("deleteid").value = deleteid;
        });
    </script>




{% endblock %}



{% block js %}
    <script src="https://cdn.bootcss.com/jquery/3.3.1/jquery.js"></script>
    <script src="https://cdn.bootcss.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
    <script src="https://cdn.bootcss.com/moment.js/2.24.0/moment-with-locales.js"></script>
    <script src="https://cdn.bootcss.com/bootstrap-datetimepicker/4.17.47/js/bootstrap-datetimepicker.min.js"></script>
    <script src="{{ buildStaticUrl('/js/parter/parterdetail.js') }}"></script>

{% endblock %}

